<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>

<script src="${ctx}/includes/jquery.js" type="text/javascript"></script>
<script src="${ctx}/includes/jquery.form.js" type="text/javascript"></script>
<script src="${ctx}/includes/jquery.validate.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="${ctx}/style/form_table.css">
<script>
$(function(){
	$("#edit_taskProcess_form").validate({
		errorPlacement: function(error, element){
            $(element).next('.field_notice').hide();
            $(element).after(error);
       },
	   success: function(label){   
	       label.addClass('right').text('OK!');
	   },
	   rules:   
	   {
	    	fgldxm : {required : true}
	   },   
	   message:{
	    	fgldxm : {required : '请输入分管领导'}
	   }
	});  
});
</script>
<s:form id="edit_taskProcess_form" name="edit_zdxzdcProcess_form" method="post" action="taskProcess/update.do" enctype="multipart/form-data" onsubmit="return false;">
	<s:token/>
	<s:hidden id="taskid" name="id" />
	<s:hidden id="jlid" name="jlid" />
	<table class="form-table">
		<tr>
			<th width="150">日期：</th>
			<td>
			${rqString }
			</td>
		</tr>
		<tr>
			<th width="150">相关工作项：</th>
			<td>${xggz }</td>
		</tr>
		<tr>
			<th width="150">具体要求及时间节点：</th>
			<td>${jtyq }</td>
		</tr>
		
		<c:if test="${spzt == 1 and  cljl.zt == 0 or cljl.zt == 2}">
		<tr>
			<th width="150">完成情况：</th>
			<td>
			<textarea rows="4" name="wcqk" id="wcqk" style="width: 500px;">${cljl.wcqk}</textarea>
			</td>
		</tr>
		<tr>
			<th width="150">下一步工作计划：</th>
			<td>
			<textarea rows="4" name="xygzjh" id="xygzjh" style="width: 500px;">${cljl.xygzjh}</textarea>
			</td>
		</tr>
		</c:if>
		
		<c:if test="${spzt == 0}">
		<tr>
			<th width="150"><span class="note_red">*</span>部门领导：</th>
			<td>
			<c:if test="${sessionScope.loginInfo.userid == 19830009}">
				<select name="fgld">
				<option value="19880039">陈文劼</option>
				<option value="19910022">郭知彼</option>
				<option value="19850027">李晓光</option>
				<option value="20010091">刘弢</option>
				<option value="19880021">任文毅</option>
				<option value="19860009">谭湘</option>
				<option value="19910004">杨宗国</option>
				<option value="19840020">易龙</option>
				<option value="19900018">张元林</option>
				<option value="19930017">张劲松</option>
				<option value="20020054">徐嵚</option>
				</select>
			</c:if>
			
			<c:if test="${sessionScope.loginInfo.userid == 19880039}">
				<select name="fgld">
				<option value="19990000">王立鹏</option>
				<option value="20030005">王丽广</option>
				<option value="19870027">黄新</option>
				<option value="20020011">姚辉</option>
				<option value="20110093">欧阳宇</option>
				</select>
			</c:if>
			
			<c:if test="${sessionScope.loginInfo.userid == 20010091}">
				<select name="fgld">
				<option value="20047078">唐运辉</option>
				<option value="20020010">赵广宁</option>
				<option value="20071006">罗梅红</option>
				<option value="20060101">李晋锋</option>
				<option value="20081135">廖湘晖</option>
				<option value="20081009">张明芳</option>
				</select>
			</c:if>
			
			<c:if test="${sessionScope.loginInfo.userid == 19850027 or sessionScope.loginInfo.userid == 19910022 or sessionScope.loginInfo.userid == 19900018}">
				<select name="fgld">
				<option value="20000062">晏红文</option>
				<option value="19977022">龚芝芳</option>
				<option value="19850001">杨十力</option>
				<option value="20020030">宋建秀</option>
				<option value="20060703">王靛 </option>
				<option value="20040067">颜志伟 </option>
				</select>
			</c:if>
			
			<c:if test="${sessionScope.loginInfo.userid == 19880021}">
				<select name="fgld">
				<option value="20010090">李龙</option>
				<option value="20030072">蔡志平</option>
				<option value="20020010">赵广宁</option>
				<option value="20020054">徐嵚</option>
				</select>
			</c:if>
			
			<c:if test="${sessionScope.loginInfo.userid == 19840020}">
				<select name="fgld">
				<option value="20071025">刘力根</option>
				<option value="20070701">刘辉</option>
				</select>
			</c:if>
			
			<c:if test="${sessionScope.loginInfo.userid == 19860009}">
				<select name="fgld">
				<option value="20091018">孟祥欣</option>
				<option value="19850011">周伟生</option>
				<option value="20060706">于向军</option>
				<option value="20050012">高晋</option>
				</select>
			</c:if>
			
			
			<c:if test="${sessionScope.loginInfo.userid == 19910004}">
				<select name="fgld">
				<option value="20047210">唐吉慧</option>
				<option value="20010031">王雁</option>
				<option value="20046502">罗凌</option>
				</select>
			</c:if>
			</td>
		</tr>
		<tr>
			<th width="150"><span class="note_red">*</span>批示意见：</th>
			<td>
			<textarea rows="4" name="ldps" id="ldps" style="width: 400px;"></textarea>
			<a href="javascript:;" onclick="selectGyyj()">公用意见</a>
			</td>
		</tr>
		</c:if>
		<c:if test="${spzt == 1}">
		<c:if test="${zxzt == -1}">
		<tr>
			<th width="150">批示意见：</th>
			<td>${ldps}</td>
		</tr>
		<tr>
			<th width="150">负责人：</th>
			<td>
			<select multiple="multiple" size="5" id="users" title="请选择执行人员" name="execUsers" style="width: 120px;;border:1px solid #DAE0E5;height:120px;"></select>
			<span style="height: auto">
			<a class="btn_short" href="javascript:void(0)" title="添加用户" name="btn_addAttendUsers" id="btn_attendUsers"
				onClick="selectUser()">选择</a>
			<a class="btn_short" href="javascript:void(0)" title="删除用户" name="btn_delAttendUsers" id="btn_delAttendUsers" 
			    onClick="deleteUser();">删除</a>
			</span>
		</tr>
		</c:if>
		</c:if>
	</table>
	<div class="win-btn-panel" style="text-align: center;margin-top: 5px;">
		<c:if test="${spzt == 0}">
			<input class="btn-short" type="button" name="subbtn" id="spwc" value="审批完成" title="点击审批完成" onClick="shfp();"/>
		</c:if>
		<c:if test="${spzt == 1}">
			<c:if test="${zxzt == -1}">
			<input class="btn-short" type="button" name="subbtn" id="fpzx" value="分配执行" title="点击分配执行" onClick="zxfp();"/>
			</c:if>
			<c:if test="${cljl.zt == 0 or cljl.zt == 2}">
				<input class="btn-short" type="button" name="subbtn" id="tjwc" value="提交完成" title="点击提交完成" onClick="zxcl();"/>
			</c:if>
			<c:if test="${cljl.zt == 3}">
				<input class="btn-short" type="button" name="subbtn" id="tjsh" value=" 同意 " title="点击提交审核" onClick="zxsh();"/>
				<input class="btn-short" type="button" name="subbtn" id="tjsh" value=" 退回 " title="审核退回" onClick="zxshth();"/>
			</c:if>
		</c:if>
	</div>
	<div style="">
	</div>
</s:form>

<c:if test="${sessionScope.loginInfo.userid == fgld }">
<c:forEach items="${cljlList}" var="item" varStatus="status">
<c:if test="${spzt == 1 and item.zt == 3}">
<form id="sh_taskProcess_form${status.index}" name="sh_zdxzdcProcess_form" method="post" action="${ctx}/taskProcess/update.do" onsubmit="return false;">
<s:token/>
<s:hidden id="taskid" name="id" />
<input type="hidden" name="jlid" value="${item.id}"/>
<table class="form-table">
<tr>
	<th width="150">执行人：</th>
	<td>${item.zxrxm }</td>
</tr>
<tr>
	<th width="150">完成情况：</th>
	<td>
	<textarea rows="4" name="wcqk" id="wcqk" style="width: 500px;">${item.wcqk}</textarea>
	</td>
</tr>
<tr>
	<th width="150">下一步工作计划：</th>
	<td>
	<textarea rows="4" name="xygzjh" id="xygzjh" style="width: 500px;">${item.xygzjh}</textarea>
	</td>
</tr>
<tr>
	<th width="150">是否完成：</th>
	<td>
	<s:radio name="isywc" list="#{'1':'是','0':'否'}" value="0"></s:radio>
	<label style="color: red;">如果存在下一步工作计划，请选择“否”</label>
	</td>
</tr>
<tr>
	<td colspan="2">
		<div class="win-btn-panel" style="text-align: center;margin-top: 5px;">
			<input class="btn-short" type="button" name="subbtn" id="tjsh" value=" 同意 " title="点击提交审核" onClick="zxsh2(this);"/>
			<input class="btn-short" type="button" name="subbtn" id="tjsh" value=" 退回 " title="审核退回" onClick="zxshth2(this);"/>
		</div>
	</td>
</tr>
</table>
</form>
</c:if>
</c:forEach>
</c:if>

<script type="text/javascript">
//var api = frameElement.api, W = api.opener;

function selectGyyj(){

	var str = '<div style="text-align: left">';
		str += '	<input type="radio" class="checkitem" name="yj" value="请尽快完成督办事项"/>请尽快完成督办事项<br/>';
		str += '	<input type="radio" class="checkitem" name="yj" value="请做好任务计划，并执行"/>请做好任务计划，并执行<br/>';
		str += '	<input type="radio" class="checkitem" name="yj" value="请做好预案，动态跟踪反馈"/>请做好预案，动态跟踪反馈<br/>';
		str += '</div>';
	parent.$.dialog({
		id:'selectyj',
		lock: true,
    	background: '#FFF',
		title:'公用意见',
		width:250, 
		max:false,
  		min:false,
		content: str,
		ok: function(){ 
			if(parent.$('.checkitem:checked').length == 0){    
				alert("请选择一个信息！");
	            return false;
	        }
	       	parent.$('.checkitem:checked').each(function(){
               parent.taskprocess.$('#ldps').val(this.value);
           });
	    }, 
	    cancelVal: '关闭', 
	    cancel: true
	});
}

function selectUser(){
  parent.$.dialog({
  	id:'abc', 
  	name:'abc',
  	title:'选择人员', 
  	content: 'url:${ctx}/pub/userAllByDeptSelect.jsp?timestamp='+new Date().getTime(), 
  	max:false,
  	min:false,
  	width:600, 
  	height:450,
  	ok: function(){ 
       	var m = parent.abc.selectMoreUserByTask();
        return m; 
    }, 
    cancelVal: '关闭', 
    cancel: true
  });
}
function deleteUser(){
	var selectObj = document.getElementById("users");
	var selectOptions = selectObj.options;
	if (selectOptions == null || selectOptions.length == 0 || selectOptions.selectedIndex == -1){
		var msg="请先选择要删除的人员！";
		alert(msg);
		return;
	}
	var ilen=selectOptions.length;
	for (var i=ilen-1; i>=0; i--){
		if(selectObj[i].selected)
		    selectObj.remove(i);
	}
}

$('#zrr').click(function(){
	parent.$.dialog({
		id:'abc', 
	  	title:'选择人员', 
	  	content: 'url:${ctx}/pub/userAllByDeptSelect.jsp?timestamp='+new Date().getTime(), 
	  	max:false,
	  	min:false,
	  	width:600, 
	  	height:450,
	  	ok: function(){ 
	       	var m = parent.abc.selectOnlyUserByTask();
	        return m; 
	    }, 
	    cancelVal: '关闭', 
	    cancel: true
  	});
});
/*审批完成*/
function shfp(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	//var creater = $('#creater').val();
	//$('#zrrbh').val(creater);
	var ldps = $('#ldps').val();
	if(ldps == ''){
		alert('请填写批示意见');
		return ;
	}
	
	$('#edit_taskProcess_form').attr("action","${ctx}/zdxzdc/shfp.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
    return false;
    
}
/*执行分配任务*/
function zxfp(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	
	var selectObj = document.getElementById("users");
	var selectOptions = selectObj.options;
	if (selectOptions == null || selectOptions.length == 0){
		alert('请选择执行人');
		return;
	}
	if (selectOptions == null || selectOptions.length == 0){
		return;
	}else{
		for (var i=0;i<selectOptions.length;i++){
			selectObj[i].selected = true;
		}
	}
	
	$('#edit_taskProcess_form').attr("action","${ctx}/zdxzdc/zxfp.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
    return false;
	
}

/*执行处理任务*/
function zxcl(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	var wcqk = $('#wcqk').val();
	if(wcqk == ''){alert('请填写完成情况!');return false;}
	
	var xygzjh = $('#xygzjh').val();
	if(xygzjh == ''){alert('请填写下一步工作计划!');return false;}
	
	$('#edit_taskProcess_form').attr("action","${ctx}/zdxzdc/zxcl.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
    return false;
}
/*执行审核任务*/
function zxsh(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	
	$('#edit_taskProcess_form').attr("action","${ctx}/zdxzdc/zxsh.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
    return false;
}
/*执行审核任务*/
function zxshth(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	
	$('#edit_taskProcess_form').attr("action","${ctx}/zdxzdc/zxshth.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
    return false;
}

function resultHandler(responseXML){
	var result = responseXML.getElementsByTagName("result")[0].firstChild.nodeValue;
	var message = responseXML.getElementsByTagName("error-message")[0].firstChild.nodeValue;
	var errorType = responseXML.getElementsByTagName("error-type")[0].firstChild.nodeValue;
	if(!eval(result)&&(errorType!=2)){
		alert(message);
	}
	else{
		var curDate = new Date(); 
		alert(message);
		parent.window.location.href = "${ctx}/zdxzdc/myTask.do?opt=zdxzdc&timsStamp=" + curDate.getTime();
	}
}
function downloadFile(A){
	window.location.href='${ctx}/filedownload.do?fileAsName='+A+'&timsStamp=' + new date().getTime();
}


/*执行审核任务*/
function zxsh2(el){
	var form = el.form;
	var v = $(form).valid();
	if(!v)return false;
	
	form.action = "${ctx}/zdxzdc/zxsh.do";
	//$('#edit_taskProcess_form').ajaxSubmit(resultHandler2);
	$(form).ajaxSubmit(resultHandler2);
    return false;
}
/*执行审核任务*/
function zxshth2(el){
    var form = el.form;
	var v = $(form).valid();
	if(!v)return false;
	
	form.action = "${ctx}/zdxzdc/zxshth.do";
	//$('#edit_taskProcess_form').ajaxSubmit(resultHandler2);
	$(form).ajaxSubmit(resultHandler2);
    return false;
}

function resultHandler2(responseXML){
	var result = responseXML.getElementsByTagName("result")[0].firstChild.nodeValue;
	var message = responseXML.getElementsByTagName("error-message")[0].firstChild.nodeValue;
	var errorType = responseXML.getElementsByTagName("error-type")[0].firstChild.nodeValue;
	if(!eval(result)&&(errorType!=2)){
		alert(message);
	}
	else{
		var curDate = new Date(); 
		alert(message);
		//parent.taskprocess.window.location.reload();
		//taskprocess.src="${ctx}/zdxzdc/process.do?id=${id}";
		parent.window.location.href = "${ctx}/zdxzdc/myTask.do?opt=zdxzdc&timsStamp=" + curDate.getTime();
	}
}


</script>
